<template>
	<view class="coupon-card-wrap">
		<view class="remain">剩余：{{ couponInfo.numberSheets }}</view>
		<view class="left">
			<view class="amount">
				<text>￥</text>
				<text>{{ couponInfo.couponPrice ? couponInfo.couponPrice / 100 : 0 }}</text>
				<view>满{{couponInfo.payAmount ? couponInfo.payAmount / 100 : '--'}}元可用</view>
			</view>
			<view v-if="true" class="type">微信代金券</view>
			<view v-if="couponInfo.awardType == 1" class="type">实物</view>
			<view v-if="couponInfo.awardType == 2" class="type">虚拟券</view>
		</view>
		<view class="right">
			<view class="info">
				<view class="title">{{ couponInfo.couponName }}</view>
				<view class="pay">满{{couponInfo.payAmount ? couponInfo.payAmount / 100 : '--'}}元可用</view>
				<view class="over-time">有效期至{{ dayjs(couponInfo.eTime).format('YYYY-MM-DD') }}</view>
			</view>
			<view class="btn-wrap">
				<view class="btn" :class="{ disabled: couponInfo.numberSheets <= 0 }" @tap="onClickHandle(couponInfo)">{{ couponInfo.numberSheets <= 0 ? '已抢光' : '立即领取' }}</view>
				<!-- <view class="need">{{ couponInfo.scoreNeed }}福分</view> -->
			</view>
		</view>
	</view>
</template>

<script setup>
	import dayjs from 'dayjs'
	import { reactive, defineProps, defineEmits } from 'vue'
	
	const emits = defineEmits(['clickHandle'])
	
	const props = defineProps({
		couponInfo: {
			type: Object,
			default: {}
		}
	})
	
	function onClickHandle(e){
		// 防连点
		getApp().preventActive(()=>{
			emits('clickHandle',e)
		})
	}
	
</script>

<style lang="less" scoped>
	.coupon-card-wrap{
		width: 100%;
		height: 220rpx;
		display: flex;
		position: relative;
		box-shadow: 1px 2px 8px 0 rgba(0,0,0,0.1);
		border-radius: 26rpx;
		overflow: hidden;
		.remain{
			position: absolute;
			right: 0;
			top: 0;
			font-size: 24rpx;
			color: #24C789;
			background: #E9F9F3;
			padding: 10rpx 20rpx;
			border-radius: 0 26rpx 0 26rpx;
		}
		.left{
			width: 220rpx;
			height: 220rpx;
			// flex: 2;
			flex-shrink: 0;
			position: relative;
			
			background: url('https://jdyd-marketing-public.oss-cn-hangzhou.aliyuncs.com/yx/5d5239fd-faa0-441c-86dd-9aa4b7f3471f.png') no-repeat left top / 100% 100%;
			
			.amount{
				// padding: 46rpx 0;
				width: 220rpx;
				height: 170rpx;
				flex-shrink: 0;
				color: #fff;
				position: relative;
				overflow: hidden;
				display: flex;
				align-items: center;
				justify-content: center;
				overflow: hidden;
				position: relative;
				
				text{
					position: relative;
					z-index: 99;
					&:nth-of-type(1){
						font-weight: bold;
						font-size: 32rpx;
					}
					&:nth-of-type(2){
						font-weight: bold;
						font-size: 60rpx;
					}
				}
				view{
					font-weight: normal;
					font-size: 24rpx;
					position: absolute;
					bottom: 10rpx;
				}
			}
			.type{
				height: 52rpx;
				color: #B17622;
				text-align: center;
				line-height: 52rpx;
				font-size: 24rpx;
			}
		}
		.right{
			padding: 0 20rpx;
			box-sizing: border-box;
			width: calc(100% - 220rpx);
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #fff;
			
			.info{
				width: calc(100% - 136rpx);
				padding-right: 24rpx;
				box-sizing: border-box;
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				box-sizing: border-box;
				padding: 40rpx 0;
				gap: 20rpx;
				.title{
					font-weight: bold;
					font-size: 32rpx;
					color: #333333;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					flex-shrink: 0;
				}
				
				.pay{
					font-weight: 400;
					font-size: 24rpx;
					color: #FF8833;
				}
				.over-time{
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
				}
			}
			.btn-wrap{
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				.btn{
					width: 136rpx;
					height: 56rpx;
					background-color: #FF8833;
					box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(255,136,51,0.4);
					border-radius: 35rpx;
					color: #fff;
					font-size: 24rpx;
					line-height: 56rpx;
					text-align: center;
					
					&.disabled{
						background-color: #DDDDDD;
						color: #999999;
						box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(221,221,221,0.4);
					}
				}
				.need{
					font-size: 24rpx;
					color: #FF8833;
					margin-top: 12rpx;
				}
			}
		}
	}
</style>